﻿// Written by Tim Grant and Adam Bradford for CS3500, Nov. 2012

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ListExtensions
{
    public static class ListExtensions
    {
        
        /// <summary>
        /// If the item is not already present in the list, it will be added.
        /// Otherwise, the list is not altered.
        /// </summary>
        /// <param name="s">The string to be added to the list.</param>
        /// <returns>
        /// Returns true if the item was added to the list; 
        /// returns false if the item already existed in the list
        /// </returns>
        public static bool AddUnique(this List<string> list, string s)
        {
            if (!list.Contains(s))
            {
                list.Add(s);
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}
